<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>编辑</title>
    <link rel="stylesheet" th:href="@{/static/layui/css/layui.css}" media="all">
    <script type="text/javascript" th:src="@{/static/js/jquery-3.js}"></script>
    <script th:src="@{/static/layui/layui.js}" charset="utf-8"></script>

    <style type="text/css">
        .layui-form-selectup dl{
            top:42px;
            bottom:unset;
        }
    </style>

</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>修改友情链接</legend>
</fieldset>

<div class="layui-form-item">
    <label class="layui-form-label">ID&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${asmePO.id}" type="text" name='id' id="id" lay-verify="required" readonly="readonly" autocomplete="off"  style="width:500px;"   class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">名称&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${asmePO.name}" type="text" name='name' id="name" lay-verify="required" lay-reqtext="关于我们名称" placeholder="请输入名称" autocomplete="off"  style="width:500px;"   class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">内容&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${asmePO.content}" type="text" name='content' id="content" lay-verify="required" lay-reqtext="关于我们内容" placeholder="请输入内容" autocomplete="off"  style="width:500px;"   class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">uri路径&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${asmePO.uri}" type="text" name='uri' id="uri" lay-verify="required" lay-reqtext="uri路径" placeholder="请输入uri路径" autocomplete="off"  style="width:500px;"   class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">排序&nbsp;:</label>
    <div class="layui-input-block">
        <input th:value="${asmePO.rank}" type="text" name='rank' id="rank" lay-verify="required" lay-reqtext="排序为必填项" placeholder="请输入排序" autocomplete="off"  style="width:500px;"   class="layui-input" >
    </div>
</div>

<div class="layui-form-item">
    <label class="layui-form-label">状态&nbsp;:</label>
    <div class="layui-input-block">
        <select name="state" id="state" lay-verify="required" style="width:500px; height: 38px;" class="layui-form-selectup">
            <option value="">请选择</option>
            <option th:selected="${asmePO.state == 0}" value="0">禁用</option>
            <option th:selected="${asmePO.state == 1}" value="1">启用</option>
        </select>
    </div>
</div>

<div class="layui-form-item">
    <div class="layui-input-block">
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="editBtn">修改</button>
    </div>
</div>

<script>

    var basePath="/";

    layui.use(['form'],function () {

        var thisIndex = parent.layer.getFrameIndex(window.name);

        var form = layui.form;
        var parentLayer = parent.layer;
        form.on("submit(editBtn)",function () {
            var obj = {
                id: $("#id").val(),
                name: $("#name").val(),
                content: $("#content").val(),
                uri: $("#uri").val(),
                rank: $("#rank").val(),
                state : $("#state").val()
            };
            $.post(basePath+"asme-edit",obj,function (data) {
                if(data.success){
                    parentLayer.msg(data.message,{
                        icon: 1,
                        time: 10000
                    });
                }else{
                    parentLayer.msg(data.message,{
                        icon: 1,
                        time: 2000
                    });
                }
                //parent.location.reload()
                parentLayer.close(thisIndex);
            },"json");

        })
    })

</script>

</body>
</html>